//
//  ZYCVideoPlayerViewController.m
//  ZDSC
//
//  Created by ZDTX on 2021/9/26.
//

#import "ZYCVideoPlayerViewController.h"
#import "ZYCVideoPlayerView.h"
#import "ZYCPublicFolderModel.h"
#import <SJVideoPlayer/SJVideoPlayer.h>
@interface ZYCVideoPlayerViewController ()

@property (nonatomic, strong) ZYCVideoPlayerView *playerView;

@end

@implementation ZYCVideoPlayerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view addSubview:self.playerView];
    self.title = self.model.name;
}
-(void) viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self.playerView.player vc_viewDidAppear];
}

-(void) viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.playerView.player vc_viewWillDisappear];
    [self.playerView.player pause];
}


- (ZYCVideoPlayerView *)playerView {
    if (!_playerView) {
        _playerView = [[ZYCVideoPlayerView alloc] initWithFrame:CGRectMake(0, kNavBarAndStatusBarHeight, kScreenWidth, 210)];
    }
    return _playerView;
}
// 
- (void)setModel:(ZYCPublicFolderModel *)model{
    _model = model;
    NSString *urlStr = [NSString stringWithFormat:@"%@/zd-system-service%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"sdfz_url"],model.filePath];
    [self.playerView playWithUrlStr:urlStr title:model.name];
}

- (BOOL)shouldAutorotate {
    return NO;
}

- (BOOL)prefersHomeIndicatorAutoHidden {
    return YES;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
